{% set uniqid = uniqid ?? uniqid('job_') %}
{% set idBase = "cron-jobs-#{uniqid}" %}
{% set nameBase = "cron[jobs][#{uniqid}]" %}

{% set environments = (job.environment is defined and job.environment is not empty)
    ? job.environment : [] %}

<div id="{{ idBase }}" data-uniqid="{{ uniqid }}" data-name="{{ nameBase }}"
     class="tab-pane {{ active is defined and active ? 'active' }}">
    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-name">
            Name
        </label>
        <input type="text" id="{{ idBase }}-name"
               name="{{ nameBase }}[name]"
               placeholder="your-awesome-job-name" class="form-control"
               value="{{ job.name }}" />
        <div class="help-block">
            Optional, for reference purposes
        </div>
    </div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-user">
            User
        </label>
        <input type="text" id="{{ idBase }}-user"
               name="{{ nameBase }}[user]"
               placeholder="root" class="form-control"
               value="{{ job.user }}" />
        <div class="help-block">
            Run the job as this user
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="form-group col-xs-12">
        <label for="{{ idBase }}-command">
            Command
        </label>
        <input type="text" id="{{ idBase }}-command"
               name="{{ nameBase }}[command]"
               placeholder="echo &quot;you are beautiful&quot;" class="form-control"
               value="{{ job.command }}" />
        <div class="help-block">
            Command to have cron run
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="form-group col-xs-12">
        <label for="{{ idBase }}-environment">
            Environment Variables
        </label>
        <select id="{{ idBase }}-environment"
               name="{{ nameBase }}[environment][]"
               multiple class="form-control select-tags-editable">
            {% for environment in environments %}
                <option selected value="{{ environment }}">{{ environment }}</option>
            {% endfor %}
        </select>
        <div class="help-block">
            Should be specified exactly as they should appear in the crontab,
            e.g., <code>PATH=/bin:/usr/bin:/usr/sbin</code>.
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-minute">
            Minute
        </label>
        <input type="text" id="{{ idBase }}-minute"
               name="{{ nameBase }}[minute]"
               placeholder="" class="form-control"
               value="{{ job.minute }}" />
        <div class="help-block">
            <code>0-59</code> for a specific minute of the hour,
            or use steps, e.g., <code>*/10</code>, for every X minutes.
        </div>
    </div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-hour">
            Hour
        </label>
        <input type="text" id="{{ idBase }}-hour"
               name="{{ nameBase }}[hour]"
               placeholder="" class="form-control"
               value="{{ job.hour }}" />
        <div class="help-block">
            <code>0-23</code> for a specific hour of the day,
            or use steps, e.g., <code>*/10</code>, for every X hours.
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-weekday">
            Day
        </label>
        <input type="text" id="{{ idBase }}-weekday"
               name="{{ nameBase }}[weekday]"
               placeholder="" class="form-control"
               value="{{ job.weekday }}" />
        <div class="help-block">
            <code>0-6</code> for a specific day of the week (Sunday is 0),
            or use steps, e.g., <code>*/10</code>, for every X days
        </div>
    </div>

    <div class="form-group col-xs-12 col-sm-6">
        <label for="{{ idBase }}-month">
            Month
        </label>
        <input type="text" id="{{ idBase }}-month"
               name="{{ nameBase }}[month]"
               placeholder="" class="form-control"
               value="{{ job.month }}" />
        <div class="help-block">
            <code>1-12</code> for a specific month of the year,
            or use steps, e.g., <code>*/10</code>, for every X months.
        </div>
    </div>

    <div class="clearfix"></div>

    <input type="hidden" name="{{ nameBase }}[monthday]"
           value="{{ job.monthday }}" />
</div>
